package logging;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import Filter.Filter;

abstract class Config {
	protected String path; 
	protected String formatConsole;
	protected String formatFiles;
	protected String separator;
	protected String level;
//	protected String typeFormatConsole;
	protected String typeFormat;
	protected boolean enableConsole; 
	protected String consoleTypeFilter,consoleValueFilter;
	protected Map<String, Filter> files = new HashMap<String, Filter>();
	protected Map<String, ArrayList<String>> destinationCustom = new HashMap<String,  ArrayList<String>>();
	protected boolean hasConsoleFilter;
	protected Filter filterConsole;
	protected boolean pathValid;
	
	public String getLevelConfig(){
		 return this.level;		 
	 }

	 
	 public Map<String, Filter> getMapFiles(){
		 return this.files;
	 }
	 
	 public Map<String, ArrayList<String>> getMapDestinationCustom(){
		 return this.destinationCustom;
	 }
	  

	 
	 public boolean enableConsole(){
		 return this.enableConsole;
	 }
	 
	 
	 public String getFormatConsole(){
		 return this.formatConsole;
	 }
	 
	 public String getFormatFiles(){
		 return this.formatFiles;
	 }
	 	 
	 
	 public String getSeparator(){
		 return this.separator;
	 }

	 
	 public String getConsoleTypeFilter(){
		 return this.consoleTypeFilter;
	 }
	 
	 
	 public String getConsoleValueFilter(){
		 return this.consoleValueFilter;
	 }
	 
	 
	 public boolean hasConsoleFilter(){
		 return (this.hasConsoleFilter);
	 }
	 
	 
	 public Filter getFilterConsole(){
		 return (this.filterConsole);
	 }
	 
	 public boolean isPathValid(){
		 return (this.pathValid);
	 }
	 
	 public boolean fileExist(){
		 File file = new File(path);
		 return file.exists();
	 }
	
//	 public String getTypeFormatConsole(){
//		 return (this.typeFormatConsole);
//	 }
//		
	 public String getTypeFormat(){
		 return (this.typeFormat);
	 }
	 
	 
	
	 protected ArrayList<String> slipParameters (String chain){
			String subChain = null;
			ArrayList<String> listParameters = new ArrayList<String>();

			int pos, longitud;
			boolean out=false;
			while (!out){
				pos=chain.indexOf(",");
				if (pos >= 0) {			
					subChain=chain.substring(0, pos);
					listParameters.add(subChain.trim());
					longitud = chain.length();
					chain=chain.substring(pos+1, longitud);
				}
				else{
					listParameters.add(chain.trim());
					out=true;
				}
							
			}
			return (listParameters);
	 }
	
}
